/* The file is saved in UTF-8 codepage.
 * Check: «Stereotype», Section mark-§, Copyright-©, Alpha-α, Beta-β, Smile-☺
 */
package cz.pecinovsky.english.lootp._101_;

import cz.pecinovsky.english.lootp._000_.Run;

import cz.pecinovsky.english.lootp.utility.NamedColor;
import cz.pecinovsky.english.lootp.utility.IO;

////%I+ <114
//import cz.pecinovsky.english.lootp.shapes.Canvas;
////%I-

////%I+ <110
//import cz.pecinovsky.english.lootp.shapes.Ellipse;
//import cz.pecinovsky.english.lootp.shapes.Rectangle;
//import cz.pecinovsky.english.lootp.shapes.Triangle;
////%I-

////%I+ >110 -014
//import cz.pecinovsky.english.lootp.shapes.Mover;
//
//import cz.pecinovsky.english.lootp.shapes.Ellipse;
//import cz.pecinovsky.english.lootp.shapes.Rectangle;
//import cz.pecinovsky.english.lootp.shapes.Triangle;
////%I-

import cz.pecinovsky.english.lootp.manager.Ellipse;
import cz.pecinovsky.english.lootp.manager.Rectangle;

import cz.pecinovsky.english.lootp.manager.Mover;


import cz.pecinovsky.english.lootp.manager.CanvasManager_Envelope.               CanvasManager;



import cz.pecinovsky.english.lootp._101_.Robot_107_114.Robot;
////////////////////////////////////////////////////////////////////////////////
//%%+  +++++ End of ignored starting test - place for imports +++++

//%X+ xxxxx Start of the ovejumped text with declaration of the envelope xxxxx
/*******************************************************************************
 *<pre>
 * Previous:  No - this is a newly defined class
 * Following: No
 *
 * Project  Ppp
 *   + Aded
 *   - Removed
 *   ~ Changed
 *</pre>
 *
 * @author Rudolf PECINOVSKÝ
 * @version 6.03.2017 — 2010-11-08
 */
public class Robot_107_114
{    private Robot_107_114() {}   static
////////////////////////////////////////////////////////////////////////////////
//%X- ----- End of the ovejumped text with declaration of the envelope -----


/*******************************************************************************
 * The class {@code Robot} defines a set of unit tests
 * created in the interractive mode
 * during the first introduction of objects.
 *
 * @author Rudolf PECINOVSKÝ
 * @version 6.03.2017 — 2010-11-08
 */
public class Robot extends junit.framework.TestCase
{
    private Rectangle head;
    private Rectangle leftHand;
    private Rectangle rightHand;
    private Rectangle body;
    private Rectangle legs;
//%A+ >109
    private Ellipse   leftWheel;
    private Ellipse   rightWheel;
//%A-


//== CONSTANT CLASS ATTRIBUTES =================================================
//== VARIABLE CLASS ATTRIBUTES =================================================
//== STATIC CONSTRUCTOR (CLASS INITIALIZER, STATIC INICITALIZING BLOCK) ========
//== CONSTANT INSTANCE ATTRIBUTES ==============================================
//== VARIABLE INSTANCE ATTRIBUTES ==============================================
//== CLASS GETTERS AND SETTERS =================================================
//== OTHER NON-PRIVATE CLASS METHODS ===========================================

//##############################################################################
//== CONSTUCTORS AND FACTORY METHODS ===========================================

    /***************************************************************************
     * Creates a test with a given name.
     *
     * @param testName  The name of the created test
     */
    public Robot(String testName)
    {
        super(testName);
    }



//== PREPARATION AND CLEANING THE FIXTURE ======================================

    /***************************************************************************
     * Creates a fixture, i.e. a set of objects that will be prepared
     * before each run test.
     */
    @Override
    protected void setUp()
    {
//%I+ <109
//        head      = new Rectangle(100,  50,  50,  50);
//        body      = new Rectangle( 75, 100, 100, 125);
//        leftHand  = new Rectangle( 50, 100,  25, 100);
//        rightHand = new Rectangle(175, 100,  25, 100);
//        legs      = new Rectangle(100, 225,  50,  75);
//%I-
//%A+ >109
        head       = new Rectangle(100,  50,  50,  50, NamedColor.RED);
        body       = new Rectangle( 75, 100, 100, 125, NamedColor.CYAN);
        leftHand   = new Rectangle( 50, 100,  25, 100, NamedColor.STEELY);
        rightHand  = new Rectangle(175, 100,  25, 100, NamedColor.STEELY);
        leftWheel  = new Ellipse  ( 75, 225,  50,  50, NamedColor.BLACK);
        rightWheel = new Ellipse  (125, 225,  50,  50, NamedColor.BLACK);
//%A-
//%A+ >114
        head       .paint();
        body       .paint();
        leftHand   .paint();
        rightHand  .paint();
        leftWheel  .paint();
        rightWheel .paint();
//%A-
        IO.inform("Robot prepared");
    }


    /***************************************************************************
     * Clean up after each test.
     */
    @Override
    protected void tearDown()
    {
    }



//== ABSTRACT METHODS ==========================================================
//== INSTANCE GETTERS AND SETTERS ==============================================
//== OTHER NON-PRIVATE INSTANCE METHODS ========================================
//== PRIVATE AND AUXILIARY CLASS METHODS =======================================
//== PRIVATE AND AUXILIARY INSTANCE METHODS ====================================
//== EMBEDDED TYPES AND INNER CLASSES ==========================================
//== THE TESTS =================================================================
//
//     /***************************************************************************
//      *
//      */
//     public void testXXX()
//     {
//     }

    /***************************************************************************
     * Sweep wit the robot's lef (for viewer the right) hand.
     */
    public void testSweep()
    {
        rightHand.moveDown(-75);
        IO.pause(500);
        rightHand.moveDown(+75);
    }

//%A+ >108

    public void testColor()
    {
        NamedColor steely = NamedColor.getNamedColor("steely");
        rightHand.setColor(steely);
        leftHand .setColor(steely);
        NamedColor cyan = NamedColor.getNamedColor("cyan");
        body.setColor(cyan);
    }

//%A-
//%A+ >=110z

    public void testSmoothSweep()
    {
        Mover mover = new Mover(15);
        mover.moveBy(0, -75, rightHand);
        mover.moveBy(0,  75, rightHand);
    }

//%A-
    }

//%%- ---- Start of the ovejumped text with closing of the envelope ----
////////////////////////////////////////////////////////////////////////////////
//== TESTING CLASSES AND METHODS ===============================================
//If the class is not the testing one, the folowing two method can be removed
//%X+   Method prepared for inserting into tested classes
     /** */
     public void testFixture() {}

//%X-

    /***************************************************************************
     * Instances of the class {@code TearDown}
     * take care about cleaning up between particular tests
     * They executes the code, which is impossible to incorporate
     * into the method {@link #tearDown()},
     * until the students will not be able to program.
     */
    private static class TearDown implements Run.ITD
    {
        /** {@inheritDoc} */
        @Override
        public void cleanUp()
        {
//            Canvas.clearCanvas();
            CanvasManager.getInstance().removeAll();
        }
    }


    /***************************************************************************
     * Test method.
     */
    public static void test()
    {
        Run.tests(Robot.class,
                new TearDown(),
//                "testFixture",
//                "testSweep",
//                "testColor",
                "testSweepSmoothly",
                "");
        System.exit(0);
    }
   /** @param args Command line arguments - they are not used. */
    public static void main(String[] args)  {  test();  }
}
